package com.lp.yupao.common;

import lombok.Data;
import java.io.Serializable;

/**
 * 统一结果返回类
 *
 * @param <T>
 */
@Data
public class BaseResponse<T> implements Serializable {
    private int code; //状态码
    private T data; //数据
    private String message; //信息
    private String description; //描述

    public BaseResponse(int code, T data, String message,String description) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description= description;
    }
    public BaseResponse(int code, T data,String message) {
        //this() 调用其他构造函数
        this(code,data,message,"");
    }

    public BaseResponse(int code, T data) {
        //this() 调用其他构造函数
        this(code,null,"","");
    }

    public BaseResponse(ErrorCode errorCode){
        this(errorCode.getCode(),null,errorCode.getMessage(),errorCode.getDescription());
    }

    public BaseResponse(ErrorCode errorCode,String message,String description){
        this(errorCode.getCode(),null,errorCode.getMessage(),errorCode.getDescription());
    }
}
